﻿using Microsoft.AspNetCore.Mvc;
using Shop.Core.Share;
using Shop.IServices;

namespace Shop.WebApi.Controllers;

/// <summary>
/// 系统服务
/// </summary>
[ApiController]
[Route("Api/[controller]")]
public class SysController: ShopControllerBase
{
    private readonly ISysAppService _sysAppService;

    private readonly IUserContext _userContext;

    /// <summary>
    /// 
    /// </summary>
    /// <param name="sysAppService"></param>
    /// <param name="userContext"></param>
    public SysController(ISysAppService sysAppService
        , IUserContext userContext)
    {
        _sysAppService = sysAppService;
        _userContext = userContext;
    }

    /// <summary>
    /// 通过ID发送登录验证码
    /// </summary>
    /// <returns></returns>
    [HttpPost("SendIdCode")]
    public async Task<AppResult> SendIdCode()
        => await _sysAppService.SendLoginCode(_userContext.Id);
}